/**
 * @author jltxseo
 * *         Created by junlintianxia on 2017/06/13.
 */
fun main(args: Array<String>) {
    println("我来自123")
    for (i in 6 downTo 0 step 2) {
        println(i)
    }
    var str: ceshiCeshi = ceshiCeshi(ceshi(null))
    str?.cheshi?.Str?.let {
        println("str.len ${it.length}")
        11111
    } .let {
        println("str is $it")
        22222
    } ?: run {
        println("str is null1")
    }
    printDouble(1,2,3)
    val values = intArrayOf(1, 2, 3)
    printDouble(*values)
    printDouble(0, *values, 42)
    println("ttttttttt")
}

fun printDouble(vararg values: Int) {
    values.forEach { println(it * 2) }
}

data class ceshiCeshi(val cheshi: ceshi?)

data class ceshi(val Str : String?)

fun ceshi() {
    println("str is null")
}

fun getStringLength(obj: Any): Int? {
    if (obj is String && obj.length > 0) {
        return obj.length
    }
    return null
}

fun describe(obj: Any): String = when (obj) {
    1 -> "One"
    "Hello" -> "Greeting"
    is Long -> "Long"
    else -> "unknown"
}

fun testNPE(ary: String?) {
    println(ary?.length)
    println(ary!!.length)
}


